﻿using SapaFinance.Domain.Model;
using Xunit;

namespace SapaFinance.Tests
{
    public class AgentTest
    {
        public static Agent Create()
        {
            var agent = new Agent("Офшор 1");
            return agent;
        }

        [Fact]
        public void CheckAgentCreate()
        {
            var agent = Create();
            Assert.NotNull(agent);
            Assert.False(agent.IsSelfAgent);
            Assert.Equal("Офшор 1", agent.Name);
            agent.IsSelfAgent=true;
            Assert.True(agent.IsSelfAgent);
            agent.Name="Офшор 2";
            Assert.Equal("Офшор 2", agent.Name);
        }

        [Fact]
        public void CheckAgentEqual()
        {
            var agent = Create();
            var agent1 = Create();
            Assert.Equal(agent1, agent);
        }

        //[Fact]
        //public void CheckAddCorporationToAgent()
        //{
        //    var agent = Create();
        //    var corporation = CorporationTest.Create();
        //    agent.AddLegalEntity(corporation);
        //    Assert.NotNull(agent);
        //    Assert.Equal(1, agent.Corporations.Count);
        //    Assert.Equal(agent, corporation.Agent);
        //}

        //[Fact]
        //public void CheckDeleteCorporationFromAgentAndClearRecordInCorporation()
        //{
        //    var agent = Create();
        //    var corporation = CorporationTest.Create();
        //    var user = UserTest.Create();
        //    agent.AddLegalEntity(corporation);
        //    agent.Delete(corporation, user);
        //    Assert.Equal(0, agent.Corporations.Count);
        //    Assert.Null(corporation.Agent);
        //    Assert.Equal(user, corporation.DeletedBy.User);

        //}

    }
}